/**
 * 入口程序
 */

var app = require('./app');
var config = require("./config.json")
var log4js = require('log4js') ;
var fs = require("fs")

var http = require("http")
var log;

//日志配置	
if(!fs.existsSync("logs"))	fs.mkdirSync("logs")	
log4js.configure(require("./log4js.json"));	
log = log4js.getLogger('main');

//数据库初始化
require("./db").init(config.mysql);

var server = http.createServer(app);

server.listen(config.port);
server.on('error', function(err){
    log.error(err.stack || err);
});
server.on('listening', function(){
    log.info("服务器已经启动", config.port)
});